package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.Article;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by anti on 2016-08-22.
 */
@Repository
public interface ArticleRepository extends JpaRepository<Article, Long>, JpaSpecificationExecutor,ArticleRepositoryCustom{

    Integer countByMallIdAndIsDelete(Long mallId, Whether isDelete);

//    @Query("select art from Article art " +
//            "where art.mallId = :mallId " +
//            "and art.isDelete= :isDelete " +
//            "and art.parentCategoryId= :categoryId " +
//            "order by art.clickCounts desc")
    List<Article> findByMallIdAndCategoryIdAndIsDelete( Long mallId,Long categoryId,Whether isDelete);


    Integer countByMallIdAndCategoryIdAndParentCategoryIdAndIsDelete(Long mallId,Long parentId,Long categoryId,Whether isDelete);

    Integer countByMallIdAndCategoryIdAndIsDelete(Long mallId, Long categoryId, Whether isDelete);
}

